import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CampusVO, CampusForm, CampusQuery } from '@/api/school/campus/types';

/**
 * 查询校区管理列表
 * @param query
 * @returns {*}
 */

export const listCampus = (query?: CampusQuery): AxiosPromise<CampusVO[]> => {
  return request({
    url: '/school/campus/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询校区管理详细
 * @param campusId
 */
export const getCampus = (campusId: string | number): AxiosPromise<CampusVO> => {
  return request({
    url: '/school/campus/' + campusId,
    method: 'get'
  });
};

/**
 * 新增校区管理
 * @param data
 */
export const addCampus = (data: CampusForm) => {
  return request({
    url: '/school/campus',
    method: 'post',
    data: data
  });
};

/**
 * 修改校区管理
 * @param data
 */
export const updateCampus = (data: CampusForm) => {
  return request({
    url: '/school/campus',
    method: 'put',
    data: data
  });
};

/**
 * 删除校区管理
 * @param campusId
 */
export const delCampus = (campusId: string | number | Array<string | number>) => {
  return request({
    url: '/school/campus/' + campusId,
    method: 'delete'
  });
};

/**
 * 修改校区管理
 * @param data
 */
export const getCampusList = (): Promise<CampusVO> => {
  return request({
    url: '/school/campus/getCampusList',
    method: 'get'
  });
};


export const getSchoolTreeNode = () => {
  return request({
    url: '/school/campus/getSchoolTreeNode',
    method: 'get'
  });
};